{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "58504e50",
   "metadata": {},
   "outputs": [],
   "source": [
    "## import IL Data\n",
    "import pandas as pd\n",
    "IL_delegations = pd.read_excel(\"C:\\\\Users\\\\Nir\\Dropbox\\\\Codification\\\\Law-Regulation Research\\\\Nir PhD\\\\paper 2\\\\Submission\\\\IL_delegations.xlsx\")\n",
    "IL_delegations_dict = IL_delegations.to_dict(\"records\")\n",
    "\n",
    "#count the total number of delegations by type\n",
    "il_delegations = 0\n",
    "il_man_delegations = 0\n",
    "il_per_delegations = 0\n",
    "\n",
    "for delegation in IL_delegations_dict:\n",
    "    il_delegations +=1\n",
    "    if delegation['del_type'] == 'mandatory':\n",
    "        il_man_delegations +=1\n",
    "    else:\n",
    "        il_per_delegations +=1\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "85eab6f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "## import UK Data\n",
    "UK_delegations = pd.read_excel(\"C:\\\\Users\\\\Nir\\\\Dropbox\\\\Codification\\\\Law-Regulation Research\\\\Nir PhD\\\\paper 2\\\\Submission\\\\UK_delegations.xlsx\")\n",
    "UK_delegations_dict = UK_delegations.to_dict(\"records\")\n",
    "\n",
    "#count the total number of delegations by type\n",
    "uk_delegations = 0\n",
    "uk_man_delegations = 0\n",
    "uk_per_delegations = 0\n",
    "\n",
    "for delegation in UK_delegations_dict:\n",
    "    uk_delegations +=1\n",
    "    \n",
    "    if delegation['delegation_type'] == 'mandatory':\n",
    "        uk_man_delegations +=1\n",
    "    else:\n",
    "        uk_per_delegations +=1\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "2a47cc7e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "------------------  ---  -----------------  ------  ------------------\n",
      "Type of Delegation  UK   UK_percentage      Israel  Israel_Percentage\n",
      "mandatory           36   5.128205128205128  150     61.224489795918366\n",
      "permissive          666  94.87179487179486  95      38.775510204081634\n",
      "total               702  100%               245     100%\n",
      "------------------  ---  -----------------  ------  ------------------\n"
     ]
    }
   ],
   "source": [
    "#create table 2 using tabulate\n",
    "from tabulate import tabulate\n",
    "\n",
    "table = [['Type of Delegation', 'UK', 'UK_percentage', 'Israel', 'Israel_Percentage'], \n",
    "         ['mandatory', uk_man_delegations, uk_man_delegations/uk_delegations*100, il_man_delegations, il_man_delegations/il_delegations*100],\n",
    "         ['permissive', uk_per_delegations, uk_per_delegations/uk_delegations*100, il_per_delegations, il_per_delegations/il_delegations*100],\n",
    "         ['total',uk_delegations, '100%', il_delegations, '100%']] \n",
    "\n",
    "print(tabulate(table))\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
